<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Company extends Seller_Controller
{
	private static $data = array();
	protected $models=['company_model','type_model'];
	public function __construct()
	{
		parent::__construct();
		$this->checkUserFlag();
	}
	//加载页面
	public function index()
	{
	    $userId=$this->getSellerId();
	    
	    $company=$this->company_model->getWhereRow(['userId'=>$userId]);       //公司数据	   
	    $company['serviceTypeIds']=explode('|', $company['serviceTypeIds']);
	    $trade=$this->type_model->getWhere(['flag'=>1]);       //行业数据
	    $service=$this->type_model->getWhere(['flag'=>9]);     //服务数据
	    self::$data['company']=$company;
	    self::$data['trade']=$trade;
	    self::$data['service']=$service;
	    $this->load->view('seller/company/info.html',self::$data);
	}
	//企业用户认证
	public function save(){
	    $data=$this->input->post();
	    $data=unsetArray_key($data,'file');       //删除file键
	    if(isset($data['serviceTypeIds'])){
	        $data['serviceTypeIds']=implode('|', $data['serviceTypeIds']);
	    }else{
	        $data['serviceTypeIds']='';
	    }
	    if(isset($data['companyId'])&&!empty($data['companyId'])){     //已存在则更新	        
	        $res=$this->company_model->updateWhere(['companyId'=>$data['companyId']],$data);
	    }else{     //不存在则插入
	        $res=$this->company_model->insert_time($data);
	    }
	    
	    if ($res){
	        show200();
	    }else {
	        show400();
	    }
	}
    
}
/* End of file Login.php */